TeeChartPHP
[ class tree: TeeChartPHP ] [ index: TeeChartPHP ] [ all elements ]

Source for file roundedCornersOnTheFly.php

Documentation is available at roundedCornersOnTheFly.php

  1. <?php
  2. $color = "fffefe";
  3. $bg_color = "99e1e0"; 
  4.  
  5. $c_width = 50;
  6. $c_height = 50;
  7.  
  8. $placement = "tr";
  9.  
  10. $width = 2 * 50;
  11. $height = 2 * 50;
  12.  
  13. // create a blank image
  14. $image = imagecreatetruecolor($c_width, $c_height);
  15.  
  16. // fill the corner color
  17. $col_ellipse = hex2int($image, $color);
  18.  
  19. // fill the background color
  20.  
  21. $bg = hex2int($image, $bg_color);
  22.  
  23. // fill the background color
  24. imagefill($image, 0, 0, $bg);
  25.  
  26. // draw the ellipse
  27. //takes (resource image, int cx, int cy, int w, int h, int color)
  28.  
  29. // bottom right corner
  30. if ($placement == "br") {imagefilledellipse($image, 0, 0, $width, $height, $col_ellipse);}
  31.  
  32. // top right corner
  33. if ($placement == "tl") {imagefilledellipse($image, $c_width, $c_height, $width, $height, $col_ellipse);}
  34.  
  35. // top left corner
  36. if ($placement == "tr") {imagefilledellipse($image, 0, $c_height, $width, $height, $col_ellipse);}
  37.  
  38. // bottom left corner
  39. if ($placement == "bl") {imagefilledellipse($image, $c_width, 0, $width, $height, $col_ellipse);}
  40.  
  41. // output the picture
  42. header("Content-type: image/png");
  43. imagepng($image);
  44.  
  45. function hex2int($image, $color) {
  46.   $string = str_replace("#","",$color);
  47.   $red = hexdec(substr($string,0,2));
  48.   $green = hexdec(substr($string,2,2));
  49.   $blue = hexdec(substr($string,4,2));
  50.  
  51.   $color_int = imagecolorallocate($image, $red, $green, $blue);
  52.   return($color_int);
  53. }
  54. ?>

Documentation generated on Wed, 16 Jun 2010 12:07:35 +0200 by phpDocumentor 1.4.1